package com.cnhis.cloudhealth.clinical.hosnurse.hosinspectionreport.bo;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.cnhis.cloudhealth.clinical.hosnurse.hosinspectionreport.dao.HosInspectionReportDao;
import com.cnhis.cloudhealth.commons.Mappers.ModelVo;
import com.cnhis.cloudhealth.commons.utils.Page;
import com.cnhis.cloudhealth.commons.utils.StaticKeys;

@Service
public class HosInspectionReportBo {
  @Resource
  private HosInspectionReportDao hosInspectionReportDao;
  
  public ModelVo viewInspectionReport(Map map)throws Exception{
	  ModelVo mo = new ModelVo();
		List ls =null;
		try {
			ls=hosInspectionReportDao.viewInspectionReport(map);
			
		} catch (Exception e) {
			e.printStackTrace();
			mo.setResult(StaticKeys.OH_FALSE);
			return mo;
		}
		mo.setList(ls);
		mo.setResult(StaticKeys.OH_SUCCESS);
		mo.setRows(ls);
		return mo;
  }
  public ModelVo findDefaultDevice()throws Exception{
	  ModelVo mo = new ModelVo();
		List ls =null;
		try {
			ls=hosInspectionReportDao.findDefaultDevice();
			
		} catch (Exception e) {
			e.printStackTrace();
			mo.setResult(StaticKeys.OH_FALSE);
			return mo;
		}
		mo.setList(ls);
		mo.setResult(StaticKeys.OH_SUCCESS);
		mo.setRows(ls);
		return mo;
  }
  public ModelVo nurseViewInspectionReport(Map map)throws Exception{
	  ModelVo mo = new ModelVo();
		List ls =null;
		try {
			ls=hosInspectionReportDao.nurseViewInspectionReport(map);
			
		} catch (Exception e) {
			e.printStackTrace();
			mo.setResult(StaticKeys.OH_FALSE);
			return mo;
		}
		mo.setList(ls);
		mo.setResult(StaticKeys.OH_SUCCESS);
		mo.setRows(ls);
		return mo;
  }
  public ModelVo reportImage(Map map)throws Exception{
	  ModelVo mo = new ModelVo();
		List ls =null;
		try {
			ls=hosInspectionReportDao.reportImage(map);
			
		} catch (Exception e) {
			e.printStackTrace();
			mo.setResult(StaticKeys.OH_FALSE);
			return mo;
		}
		mo.setList(ls);
		mo.setResult(StaticKeys.OH_SUCCESS);
		mo.setRows(ls);
		return mo;
  }
  public ModelVo doctorViewInspectionReport(Map map)throws Exception{
	  ModelVo mo = new ModelVo();
		List ls =null;
		try {
			ls=hosInspectionReportDao.doctorViewInspectionReport(map);
			
		} catch (Exception e) {
			e.printStackTrace();
			mo.setResult(StaticKeys.OH_FALSE);
			return mo;
		}
		mo.setList(ls);
		mo.setResult(StaticKeys.OH_SUCCESS);
		mo.setRows(ls);
		return mo;
  }
  @SuppressWarnings("unchecked")
  public ModelVo doctorViewInspectionReportResult(Map map)throws Exception{
	  ModelVo mo = new ModelVo();
		List ls =null;
		try {
			boolean flag = hosInspectionReportDao.BLP58(map)>0;
			if(!flag){
				map.put("flag", 1);
			}
			ls=hosInspectionReportDao.doctorViewInspectionReportResult(map);
			
		} catch (Exception e) {
			e.printStackTrace();
			mo.setResult(StaticKeys.OH_FALSE);
			return mo;
		}
		mo.setList(ls);
		mo.setResult(StaticKeys.OH_SUCCESS);
		mo.setRows(ls);
		return mo;
   }
  public ModelVo patientDynamicMonitor(Map map,int currPage,int pageSize)throws Exception{
	  ModelVo mo = new ModelVo();
		Page page =new Page();
		try {
			page=hosInspectionReportDao.patientDynamicMonitor(map, currPage, pageSize);
			
		} catch (Exception e) {
			e.printStackTrace();
			mo.setResult(StaticKeys.OH_FALSE);
			return mo;
		}
		mo.setList(page.getList());
		mo.setResult(StaticKeys.OH_SUCCESS);
		mo.setRows(page.getList());
		return mo;
	  
  }
  public ModelVo dangerValueTips(Map map,int currPage,int pageSize) throws Exception{
	  
	  ModelVo mo = new ModelVo();
		Page page =new Page();
		try {
			page=hosInspectionReportDao.dangerValueTips(map, currPage, pageSize);
			
		} catch (Exception e) {
			e.printStackTrace();
			mo.setResult(StaticKeys.OH_FALSE);
			return mo;
		}
		mo.setList(page.getList());
		mo.setResult(StaticKeys.OH_SUCCESS);
		mo.setRows(page.getList());
		return mo;
  }
}
